package com.trkj.dao.jpa;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.trkj.pojos.YzrMedPurchDet;

public interface IYzrMedPurchDetDAO extends CrudRepository<YzrMedPurchDet, String> {
	//根据编号前缀查询出最大的编号
	@Query("select max(mpd.purchDetId) from YzrMedPurchDet mpd where mpd.purchDetId like ?1%")
	public String findID(String a);	
	
	//查询所有计划
	@Query("select mpd from YzrMedPurchDet mpd where mpd.purchDetPurchId=?1 order by mpd.purchDetId asc")
	public List<YzrMedPurchDet> findAll(String purchId,Pageable pageable);
	//查询所有计划
	@Query("select mpd from YzrMedPurchDet mpd where mpd.purchDetPurchId=?1 order by mpd.purchDetId asc")
	public List<YzrMedPurchDet> findAll2(String purchId);
	
	//根据采购编号查找出明细条数
	@Query("select count(*) from YzrMedPurchDet mpd where mpd.purchDetPurchId=?1")
	public long findByCount(String purchId);
	
	//根据采购计划id查找出计划明细
	@Query("select mpd from YzrMedPurchDet mpd where mpd.purchDetPurchId=?1")
	public List<YzrMedPurchDet> findByPurchId(String purchId,Pageable pageable);
	
	//根据采购计划id查找计划明细
	@Query("select mpd from YzrMedPurchDet mpd where mpd.purchDetPurchId=?1")
	public List<YzrMedPurchDet> findByPurchId2(String purchId);
	
	
}
